package 剑指offer;

public class _57和为s的两个数字 {
    public int[] twoSum(int[] nums, int target) {
        int len = nums.length;
        int left = 0;
        int right = len-1;
        while(left < right) {
            if(nums[left] + nums[right] == target) {
                return new int[]{nums[left], nums[right]};
            } else if(nums[left] + nums[right] < target) {
                left++;
            } else {
                right--;
            }
        }
        return new int[2];
    }
}
